package forList;

public class HashSetTest {

    public static void main(String[] args) {

        Node[] table = new Node[16];
        Node john = new Node("john", null);
        Node jack = new Node("jack", null);
        Node rose = new Node("rose", null);
        john.next = jack;
        jack.next = rose;
        table[2] = john;

        for (int i = 0; i < table.length; i++) {
            if (table[i] != null && table[i].next != null) {
                System.out.printf("索引:%s --> 内容:%s --> next:%s\n", i, table[i].content, table[i].next.content);
            } else if (table[i] != null) {
                System.out.printf("索引:%s --> 内容:%s --> next为null\n", i, table[i].content);
            } else {
                System.out.printf("索引:%s --> %s\n", i, "null");
            }
        }
    }

}

class Node { //节点,可以存储数据,并指向下一个节点,从而形成链表

    // 存储数据
    Object content;
    // 指向下一个节点
    Node next;

    public Node(Object content, Node next) {

        this.content = content;
        this.next = next;
    }

}
